package com.mapproject.industrymap.controller;
import com.mapproject.industrymap.service.SysUserService;
import com.mapproject.industrymap.utils.EncodeMd5;
import com.mapproject.industrymap.utils.JwtUtil;
import com.mapproject.industrymap.utils.ReturnValue;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/login")
public class SysLoginController {

    @Autowired
    SysUserService sysUserService;
    @PostMapping("/normallogin")
    public Object login(@RequestBody Map<String,String> userinfo) throws Exception {

        String username=userinfo.get("username");
        String password=userinfo.get("password");
        if(username.isEmpty()||username.equals("")||password.isEmpty()||password.equals("")){
            return new ReturnValue(500,"用户名或密码为空");
        }else{
            EncodeMd5 encodeMd5=new EncodeMd5();
            String pass=encodeMd5.MD5(userinfo.get("password"));
            return   sysUserService.normallogin(username,pass);
        }
    }

}
